package shuati;

/**
 * @date:2022/9/25
 * @author:CqLtd
 * @name:质数的和与积
 */

import java.util.Scanner;

public class p2 {

    public static void main(String[] args) {
        int sum,mul = 0,temp = 0;
        Scanner sc = new Scanner(System.in);
        sum = sc.nextInt();
        for (int i= (sum/2); i >= 2; i--) {
            if (prime(i)==1 && prime(sum-i)==1) {
                temp = i*(sum-i);
                if (temp >= mul) {
                    mul = temp;
                }
            }
        }
        System.out.println(mul);
    }
    static int prime(int n){
        for (int j = 2; j <n; j++) {
            if (n % j == 0) {
                return 0;
            }
        }
        return 1;
    }
}